package cn.wolfcode.domain;

import cn.wolfcode.student.domain.Student;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageResult<T> {
    private  int currentPage;
    private  int pageSize;
    private  int totalPage;
    private  int totalCount;
    private  int prevPage;
    private  int nextPage;
    private List<T> data;

    public PageResult(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
        totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        prevPage = currentPage - 1 >= 1 ? currentPage - 1 : 1;
        nextPage = currentPage+1<=totalPage?currentPage+1:totalPage;
    }
}
